#ifndef __DVC_MINIPC_H__
#define __DVC_MINIPC_H__

/*=============================Include========================================*/

#include "drv_uart.h"
/*==============================ExportedMacros================================*/

/*=============================ExportedTypes==================================*/
typedef struct vision_rx_data {
	bool tracking;           // 代表当前是否锁定目标
	uint8_t id : 3;          // 0-outpost 6-guard 7-base
	uint8_t armors_num : 3;  // 2-balance 3-outpost 4-normal
	float yaw;
	float pitch;
	float fire;
	float v_yaw;
	float distance;
	float is_fire;
} __packed vision_rx_data_t;

typedef struct vision_tx_data {
	uint8_t detect_color : 1;  // 0-red 1-blue
	bool reset_tracker : 1;
	uint8_t reserved : 6;
	float roll;
	float pitch;
	float yaw;
} __packed vision_tx_data_t;

/*-----------------------------------*/

typedef struct navigation_rx_data {
	float a;
	float b;
	float c;
} __packed navigation_rx_data_t;

typedef struct navigation_tx_data {
} __packed navigation_tx_data_t;

/*-----------------------------------*/

typedef struct referee_tx_data {
} __packed referee_tx_data_t;

typedef enum { VERSION_LABLE = 1, NAVIGATION_LABLE, REFEREE_LABLE } lable_e;

typedef struct frame {
	uint8_t head1 = 0xAA;
	uint8_t head2 = 0x55;
	lable_e lable;
	uint16_t length;
	uint8_t data[100];
	uint16_t check_sum;
} __packed frame_t;

class miniPC {
   public:
	vision_rx_data_t vs_rx_data;
	vision_tx_data_t vs_tx_data;

	navigation_rx_data_t nvg_rx_data;
	navigation_tx_data_t nvg_tx_data;

	referee_tx_data_t ref_tx_data;
	frame_t tx_frame;
	void init(UART_HandleTypeDef *_huart);

	void send_packet_data(lable_e _lable, vision_tx_data_t *_struct_data,
	                      uint16_t _length);
	void send_packet_data(lable_e _lable, navigation_tx_data_t *_struct_data,
	                      uint16_t _length);
	void send_packet_data(lable_e _lable, referee_tx_data_t *_struct_data,
	                      uint16_t _length);

	void UART_RxCallback(uint8_t *_rx_data);

   protected:
	uart_manager_t *uart_manager;

	uint8_t tx_buffer[256];

	uint16_t data_packet();
	void unpacking();
};
/*=============================ExportedDefinitions============================*/

/*=============================ExportedFunctionDeclarations===================*/

#endif

/*========================COPYRIGHT(C) CCUT-DAMOCLES==========================*/
